Check the mtime of all directories, not just the toplevel, if ftw() is
authorMatthias Clasen <mclasen@redhat.com>
Sat, 27 Jan 2007 04:27:38 +0000 (04:27 +0000)
committerMatthias Clasen <matthiasc@src.gnome.org>
Sat, 27 Jan 2007 04:27:38 +0000 (04:27 +0000)
2007-01-26  Matthias Clasen  <mclasen@redhat.com>

        * gtk/updateiconcache.c: Check the mtime of all directories,
        not just the toplevel, if ftw() is available.  (#331671, Behdad
        Esfahbod)

        * configure.in: Check for ftw.h.

svn path=/trunk/; revision=17221

ChangeLog
gtk/updateiconcache.c

index ea83d9a4ad55157f759f740d63740c96ee6f8391..dbfbeb7b60571b91b01d7e633c2595c545a00810 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-01-26  Matthias Clasen  <mclasen@redhat.com>
+
+       * gtk/updateiconcache.c: Check the mtime of all directories,
+       not just the toplevel, if ftw() is available.  (#331671, Behdad
+       Esfahbod)
+
+       * configure.in: Check for ftw.h.
+
 2007-01-26  Michael Natterer  <mitch@imendio.com>
 
        * modules/input/gtkimcontextxim.c (gtk_im_context_xim_finalize):
index 5aec9a2f00b4642f3b946e0234f99eb382cd6671..a9c4cb7347d8b587a651a2f46f41c4a5656ecf2f 100644 (file)
@@ -62,16 +62,62 @@ static gchar *var_name = "-";
 #define ALIGN_VALUE(this, boundary) \
   (( ((unsigned long)(this)) + (((unsigned long)(boundary)) -1)) & (~(((unsigned long)(boundary))-1)))
 
-static gboolean
+#ifdef HAVE_FTW_H
+
+#include <ftw.h>
+
+static struct stat cache_stat;
+static gboolean cache_up_to_date;
+
+static int check_dir_mtime (const char        *dir, 
+                            const struct stat *sb,
+                            int                tf)
+{
+  if (tf != FTW_NS && sb->st_mtime > cache_stat.st_mtime)
+    {
+      cache_up_to_date = FALSE;
+      /* stop tree walk */
+      return 1;
+    }
+
+  return 0;
+}
+
+ gboolean
+ is_cache_up_to_date (const gchar *path)
+ {
+  gchar *cache_path;
+  gint retval;
+
+  cache_path = g_build_filename (path, CACHE_NAME, NULL);
+  retval = g_stat (cache_path, &cache_stat);
+  g_free (cache_path);
+  
+  if (retval < 0)
+    {
+      /* Cache file not found */
+      return FALSE;
+    }
+
+  cache_up_to_date = TRUE;
+
+  ftw (path, check_dir_mtime, 20);
+
+  return cache_up_to_date;
+}
+
+#else  /* !HAVE_FTW_H */
+
+gboolean
 is_cache_up_to_date (const gchar *path)
 {
   struct stat path_stat, cache_stat;
   gchar *cache_path;
-  int retval;
+  int retval; 
   
   retval = g_stat (path, &path_stat);
 
-  if (retval < 0)
+  if (retval < 0) 
     {
       /* We can't stat the path,
        * assume we have a updated cache */
@@ -92,6 +138,8 @@ is_cache_up_to_date (const gchar *path)
   return cache_stat.st_mtime >= path_stat.st_mtime;
 }
 
+#endif  /* !HAVE_FTW_H */
+
 static gboolean
 has_theme_index (const gchar *path)
 {